package com.freshcity.page.home
{
	import com.freshcity.component.BaseGameObject;
	import com.freshcity.core.MainScene;
	import com.freshcity.core.OpCodes;
	import com.freshcity.manager.CommunicatorManager;
	import com.freshcity.manager.MsgManager;
	import com.freshcity.page.talk.RequestTalk;
	import com.freshcity.utils.StringUtil;
	import com.greensock.TweenLite;
	
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.events.TextEvent;
	import flash.text.TextField;

	public class MessagePanel extends BaseGameObject
	{
		public function MessagePanel(_name:String=null)
		{
			super(_name);
		}

		override public function destroy():void
		{
			super.destroy();
		}

		override public function initialize():void
		{
			super.initialize();

			group.commu=this.owningGroup.getManager(CommunicatorManager) as CommunicatorManager;
			group.commu.register(OpCodes.BROADCAST_MSG, onBroadCastMsg);
			//TweenLite.delayedCall(3, onShowMessage);
			//TweenLite.delayedCall(5, initOfflineMsg);
		}

		private function onBroadCastMsg(data:*):void
		{
			var msg:*;
			var cArray:Array;

			switch (data.type)
			{
				case 5:
				{
					msg="用户".concat(StringUtil.addColor(data.content, "#339900"), "已加你为意中人了！");
					group.msg.showPopUpMsg(msg, MsgManager.HAHA, 5);
					break;
				}
				case 7:
				{
					cArray=String(data.content).split(",");
					msg="用户".concat(StringUtil.addColor(cArray[0], "#339900"), "收到", StringUtil.addColor(cArray[0], "#FF0000"), "枚玫瑰，TA的美誉度正在上升！");
					group.msg.showPopUpMsg(msg, MsgManager.HAHA, 5);
					break;
				}
				case 9:
				{
					msg="用户".concat(StringUtil.addColor(data.content, "#339900"), "已申请到你的QQ号码。");
					group.msg.showFixRollMsg(msg);
					break;
				}	
				case 10:
				{
					msg="用户".concat(StringUtil.addColor(data.content, "#339900"), "轻轻的向你问了声好!");
					group.msg.showPopUpMsg(msg, MsgManager.HAHA, 5);
					break;
				}					
				default:
				{
					group.msg.showPopUpMsg(data.content, MsgManager.FEIJI, 0);
					break;
				}
			}
		}
		
	}
}
